package com.ymatou.query.trading.api.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetUserAccountInfoBean;
import com.ymatou.query.trading.api.service.GetUserAccountInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.utils.constant.ECode;

/**
 * 获取用户账户信息 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetUserAccountInfo {

	private static GetUserAccountInfoBean useraccountinfobean;
	private static GetUserAccountInfoCall useraccountinfocall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取用户账户信息");
	}

	@Before
	public void caseUp() {

		useraccountinfobean = new GetUserAccountInfoBean();
		useraccountinfocall = new GetUserAccountInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(useraccountinfocall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetUserAccountInfo_001() {
		Logger.start(true,"获取用户账户信息成功");
		try {
			// 参数
			int BuyerId = 1113;
			useraccountinfobean.setBuyerId(BuyerId);
			// 发送请求
			useraccountinfocall.setData(useraccountinfobean);
			useraccountinfocall.callService();
			Logger.comment("useraccountinfocall send:" + useraccountinfocall.getEntityString());
			Logger.comment("useraccountinfocall response:" + useraccountinfocall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// useraccountinfocall.getMsg(), "验证Msg");
			Logger.verifyEquals(true, useraccountinfocall.getAccountAmount() > 0, "验证账户余额");
			Logger.verifyEquals(true, useraccountinfocall.getGiftAmount() >= 0, "验证红包余额");
			Logger.verifyEquals(true, useraccountinfocall.getExistsTradingPwd(), "验证已设置交易密码");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUserAccountInfo_002() {
		Logger.start(true,"用户id为空");
		try {
			// 参数
			int BuyerId = 1113;
			// useraccountinfobean.setBuyerId(BuyerId);
			// 发送请求
			useraccountinfocall.setData(useraccountinfobean);
			useraccountinfocall.callService();
			Logger.comment("useraccountinfocall send:" + useraccountinfocall.getEntityString());
			Logger.comment("useraccountinfocall response:" + useraccountinfocall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// useraccountinfocall.getMsg(), "验证Msg");
			Logger.verifyEquals(true, useraccountinfocall.getAccountAmount() == 0, "验证账户余额");
			Logger.verifyEquals(true, useraccountinfocall.getGiftAmount() == 0, "验证红包余额");
			Logger.verifyEquals(false, useraccountinfocall.getExistsTradingPwd(), "验证已设置交易密码");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetUserAccountInfo_003() {
		Logger.start(true,"用户id不存在");
		try {
			// 参数
			int BuyerId = 1113;
			useraccountinfobean.setBuyerId(1);
			// 发送请求
			useraccountinfocall.setData(useraccountinfobean);
			useraccountinfocall.callService();
			Logger.comment("useraccountinfocall send:" + useraccountinfocall.getEntityString());
			Logger.comment("useraccountinfocall response:" + useraccountinfocall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, useraccountinfocall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// useraccountinfocall.getMsg(), "验证Msg");
			Logger.verifyEquals(true, useraccountinfocall.getAccountAmount() == 0, "验证账户余额");
			Logger.verifyEquals(true, useraccountinfocall.getGiftAmount() == 0, "验证红包余额");
			Logger.verifyEquals(false, useraccountinfocall.getExistsTradingPwd(), "验证已设置交易密码");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}